"""应用配置"""
from typing import Optional
from pydantic_settings import BaseSettings
from functools import lru_cache


class Settings(BaseSettings):
    """应用设置类"""
    # 应用配置
    app_name: str = "FastAPI Server"
    debug: bool = True
    host: str = "0.0.0.0"
    port: int = 8000
    
    # 数据库配置
    database_url: str
    
    # Redis配置
    redis_url: str
    
    # JWT配置
    secret_key: str
    algorithm: str = "HS256"
    access_token_expire_minutes: int = 30
    
    class Config:
        env_file = ".env"
        case_sensitive = False


@lru_cache()
def get_settings() -> Settings:
    """获取应用配置实例（单例模式）"""
    return Settings()
